package wymiana.domain;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * 
 * @author Rafal Magdon
 * @version 1.0
 * 
 *          Description:
 * 
 */
@Entity
@Table(name = "department")
public class Department extends BaseEntity {

	private static final int NORMAL_LENGTH = 255;
	private static final int MAX_LENGTH = 4000;
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(updatable = false, name = "DEPARTMENT_ID")
	private Integer idDepartment;

	@Column(length = 500, nullable = false)
	private String name;

	@Column(length = 4000, nullable = true)
	private String description;

	@Column(nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date creationDate;

	@ManyToOne
	@JoinColumn(name = "school", nullable = true)
	private School school;
	
	@OneToMany(cascade = { javax.persistence.CascadeType.ALL }, mappedBy = "department")
	private List<DGroup> dGroups;

	public Integer getIdDepartment() {
		return idDepartment;
	}

	public void setIdDepartment(Integer idDepartment) {
		this.idDepartment = idDepartment;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	public School getSchool() {
		return school;
	}

	public void setSchool(School school) {
		this.school = school;
	}

	/**
	 * @return the dGroups
	 */
	public List<DGroup> getdGroups() {
		return dGroups;
	}

	/**
	 * @param dGroups the dGroups to set
	 */
	public void setdGroups(List<DGroup> dGroups) {
		this.dGroups = dGroups;
	}

}
